// reference_cv.h

#pragma once

using namespace System;

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

#include "gdiplus.h"
#include "gdiplusImaging.h"
#pragma comment (lib,"gdiplus.lib")

namespace reference_cv {

	public ref class cv
	{
		
	    private:
			IplImage *src,*tempsrc,*hsv,*h_plane,*s_plane,*v_plane,*Plan_R,*Plan_G,*Plan_B;
            IplImage *R_src,*G_src,*B_src,*h_src,*s_src,*v_src;
			IplImage *smooth_RGB,*smooth_R,*smooth_G,*smooth_B;
            IplImage *laplace_RGB,*laplace_R,*laplace_G,*laplace_B,*laplace_V,*intlaplace_R,*intlaplace_G,*intlaplace_B;
			IplImage *canny_R,*canny_G,*canny_B;
            IplImage *Search_Img;
			CvHistogram *hist_srcH,*hist_srcS,*hist_srcV;
		    char* imagefilename,*windowname;
		public:
			
			int cv_setpath(array<byte>^file)
			{
				 imagefilename=new char[file->Length+1];
				 memset(imagefilename,0,file->Length);
				 imagefilename[file->Length]='\0';
				 for (int k=0 ;k<file->Length ;k++)
				 {
					 *(imagefilename+k)=file[k];
				 }
                src=cvLoadImage(imagefilename,CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR);
				//cv_Iniciate();

				//cv_start();
				return 0;
			}
			
			IplImage* BitmapToIplImage(HBITMAP hBmp);
			int cv_Changeback();
			int cv_setwinname(array<byte>^name);
			int cv_showImg();
			int cv_colseImg();
		    int cv_start();
			int cv_winposition(array<byte>^winname,int x,int y);
			int cv_viewhistogram();
			int cv_EqualizeHistogram();
			int cv_Allthreshold(WORD size);
			int cv_viewSeperate();
			int cv_thread(byte limt,WORD type);
			bool cv_mythread(IplImage* dest,IplImage* src,IplImage* destRGBtemp,IplImage* srcRGBtemp,byte limt);
		    bool cv_smooth(WORD type);
			bool cv_viewsmooth(WORD type);
			int cv_laplace(int size);
			int cv_viewlaplace();
			int cv_canny(int threshold1,int threshold2,int size);
			int cv_sobel(int threshold1,int threshold2,int size);
			int cv_kmeans(int nCuster);
			int cv_fixedNumhist(int histNumH,int histNumS,int histNumI);
			double cv_Comparehist(WORD type);
			int cv_BitmapToIplImage(int buffer,int stride,int width,int height,int bitCount);
		    int cv_BitmapTosrcIplImage(int buffer,int stride,int width,int height,int bitCount);
			int cv_FiguresrcHist();
			int cv_FindCircles();
			// TODO: Add your methods for this class here.
		private :
			int cv_Imgsplit();
			int cv_Iniciate();
			int cv_onehist(WORD type,IplImage *oneplan,char* winname);
			int cv_onehistH(WORD type,IplImage *oneplan,char* winname);
			int cv_fixedNumhistsub1(WORD type,IplImage *oneplan,char* winname,int histNum);
			int cv_fixedNumhistsub2(WORD type,IplImage *oneplan,char* winname,int histNum);
			int cv_histogram();
			int cv_ImgPlusthreshold(IplImage* dest,IplImage* src);
			int cv_ImgPlus(IplImage* result,IplImage* destImg);
			int cv_ImgPlushsv(IplImage* result,IplImage* destImg);
			int cv_ImgPlustlaplace();
			int cv_targethistogram(IplImage* targetImg, CvHistogram* histH,  CvHistogram* histS,  CvHistogram* histV);
	};
       
}
